Allow localization of the format in which the year is displayed. (#135451,
authorMatthias Clasen <mclasen@redhat.com>
Sun, 12 Jun 2005 06:59:43 +0000 (06:59 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sun, 12 Jun 2005 06:59:43 +0000 (06:59 +0000)
2005-06-12  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkcalendar.c (calendar_paint_header):
(gtk_calendar_size_request): Allow localization of the
format in which the year is displayed.  (#135451, Paisa
Seeluangsawat)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtkcalendar.c

index 4dee567d38c4fb7cb9c2baef820591935af753ab..cc8f11e2fd096a8098261ed49de0e33e1c400f63 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-06-12  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcalendar.c (calendar_paint_header): 
+       (gtk_calendar_size_request): Allow localization of the
+       format in which the year is displayed.  (#135451, Paisa 
+       Seeluangsawat)
+
        * gdk/*.h: Cleanup.  (#169648, Fabricio Barros Cabral)
 
        * gdk/gdkcairo.c: Small doc additions.
index 4dee567d38c4fb7cb9c2baef820591935af753ab..cc8f11e2fd096a8098261ed49de0e33e1c400f63 100644 (file)
@@ -1,5 +1,10 @@
 2005-06-12  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcalendar.c (calendar_paint_header): 
+       (gtk_calendar_size_request): Allow localization of the
+       format in which the year is displayed.  (#135451, Paisa 
+       Seeluangsawat)
+
        * gdk/*.h: Cleanup.  (#169648, Fabricio Barros Cabral)
 
        * gdk/gdkcairo.c: Small doc additions.
index 4dee567d38c4fb7cb9c2baef820591935af753ab..cc8f11e2fd096a8098261ed49de0e33e1c400f63 100644 (file)
@@ -1,5 +1,10 @@
 2005-06-12  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcalendar.c (calendar_paint_header): 
+       (gtk_calendar_size_request): Allow localization of the
+       format in which the year is displayed.  (#135451, Paisa 
+       Seeluangsawat)
+
        * gdk/*.h: Cleanup.  (#169648, Fabricio Barros Cabral)
 
        * gdk/gdkcairo.c: Small doc additions.
index 1183c34e4477ab1a6a15f4125234c6cc1aaec73b..8fe48ec2e729e24221a6986ff2dcc61fe6fd60e4 100644 (file)
@@ -1535,16 +1535,21 @@ gtk_calendar_size_request (GtkWidget      *widget,
                                               logical_rect.width + 8);
          max_header_height = MAX (max_header_height, logical_rect.height); 
        }
+
       priv->max_year_width = 0;
-      for (i=0; i<10; i++)
-       {
-         g_snprintf (buffer, sizeof (buffer), "%d%d%d%d", i,i,i,i);
-         pango_layout_set_text (layout, buffer, -1);     
-         pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
-         priv->max_year_width = MAX (priv->max_year_width,
-                                             logical_rect.width + 8);
-         max_header_height = MAX (max_header_height, logical_rect.height); 
-       }
+      /* Translators:  This is a text measurement template.
+       * Translate it to the widest year text. 
+       * 
+       * Don't include the prefix "year measurement template|" 
+       * in the translation.
+       *
+       * If you don't understand this, leave it as "2000"
+       */
+      pango_layout_set_text (layout, Q_("year measurement template|2000"), -1);          
+      pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+      priv->max_year_width = MAX (priv->max_year_width,
+                                 logical_rect.width + 8);
+      max_header_height = MAX (max_header_height, logical_rect.height); 
     } 
   else 
     {
@@ -1780,6 +1785,9 @@ calendar_paint_header (GtkCalendar *calendar)
   PangoLayout *layout;
   PangoRectangle logical_rect;
   gboolean year_left;
+  time_t tmp_time;
+  struct tm *tm;
+  gchar *str;
 
   if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) 
     year_left = priv->year_before;
@@ -1798,10 +1806,27 @@ calendar_paint_header (GtkCalendar *calendar)
                    GTK_STATE_NORMAL, GTK_SHADOW_OUT,
                    NULL, widget, "calendar",
                    0, 0, header_width, priv->header_h);
+
+  tmp_time = 1;  /* Jan 1 1970, 00:00:01 UTC */
+  tm = gmtime (&tmp_time);
+  tm->tm_year = calendar->year - 1900;
+
+  /* Translators: This dictates how the year is displayed in
+   * gtkcalendar widget.  See strftime() manual for the format.
+   * Use only ASCII in the translation.
+   *
+   * Also look for the msgid "year measurement template|2000".  
+   * Translate that entry to a year with the widest output of this
+   * msgid. 
+   * 
+   * Don't include the prefix "calendar year format|" in the 
+   * translation. "%Y" is appropriate for most locales.
+   */
+  strftime (buffer, sizeof (buffer), Q_("calendar year format|%Y"), tm);
+  str = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
+  layout = gtk_widget_create_pango_layout (widget, str);
+  g_free (str);
   
-  
-  g_snprintf (buffer, sizeof (buffer), "%d", calendar->year);
-  layout = gtk_widget_create_pango_layout (widget, buffer);
   pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
   
   /* Draw title */